package com.alibaba.sdk.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;

import java.util.ArrayList;
import java.util.List;

/**
 * 读取指定的配置文件
 *
 * @ writer Shawn(Shawn_0217@163.com)
 * @ date & time 2021/4/26 22:35
 * @ company alibaba
 */
@Configuration
public class PropertiesReaderConfig {

    @Bean
    public ResourceBundleMessageSource messageSource(){
        ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
        List<String> baseNames = new ArrayList<>();
        messageSource.setDefaultEncoding("utf-8");

        baseNames.add("application-errors");
        baseNames.add("config/application-errors");
        messageSource.setBasenames(baseNames.toArray(new String[baseNames.size()]));
        return messageSource;
    }
}
